package com.yix.jpademo.controller;

import com.yix.jpademo.dao.DeptRepository;
import com.yix.jpademo.dao.UserRepository;
import com.yix.jpademo.entity.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class DruidTestController {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    UserRepository userRepository;
    @Autowired
    DeptRepository deptRepository;

    @GetMapping("/userList")
    public List<Map<String, Object>> userList(){
        String sql = "select id from sys_user";
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        this.userRepository.getOne("4028811d762cd0b201762cd0b4f20000");
        Dept dept = new Dept();
        dept.setFullname("宁波山沟沟你只能");
        dept.setNum(1);
        dept.setPids("0");
        dept.setPid("nbsg");
        dept.setSimplename("山沟");
        this.deptRepository.save(dept);
        this.deptRepository.findAll();
        this.deptRepository.getOne("fsadf");
        return maps;
    }
}
